﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Maticsoft.Web.sysMan
{
    public partial class UpdatePass : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn_add_Click(object sender, EventArgs e)
        {
            string old = this.txt_oldPass.Text;
            string newPass = this.txt_newPass.Text;
            string rePass = this.txt_re.Text;

            if (newPass != rePass)
            {
                Maticsoft.Common.MessageBox.Show(this.Page,"两次输入密码不一致！");
                return;
            }
            if (Session["login"] != null)
            {
                Maticsoft.BLL.userInfo um = new BLL.userInfo();
                Maticsoft.Model.userInfo u = Session["login"] as Maticsoft.Model.userInfo;

                if (u.pass != old)
                {
                    Maticsoft.Common.MessageBox.Show(this.Page, "旧密码不正确！");
                }
                else
                {
                    u.pass = newPass;

                    um.Update(u);
                    Maticsoft.Common.MessageBox.Show(this.Page, "密码更改成功！");
                }
            }

        }
    }
}